package home.my.base.util;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

public class MyPropertiesHolder extends PropertyPlaceholderConfigurer {

	private Map<String, String> resolvedProps;// 将属性保存起来

	@SuppressWarnings("rawtypes")
	@Override
	protected void processProperties( ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
		super.processProperties(beanFactoryToProcess, props);
		resolvedProps = new HashMap<String, String>();
		for (Object key : props.keySet()) {
			String keyStr = key.toString();
			resolvedProps.put(keyStr, super.parseStringValue(props.getProperty(keyStr), props, new HashSet()));
		}
	}
	
	public String getProp(String key){
		return resolvedProps.get(key);
	}
}
